home *** CD-ROM | disk | FTP | other *** search
/ New Perspectives on Computer Concepts / New Perspectives on Computer Concepts.iso / np2010c / page787.pag < prev    next >
Portable Network Graphic  |  2008-10-02  |  71KB  |  817x1045  |  8-bit (256 colors)
Labels: chat room | hakham | monitor | sky
OCR: COMPUTER PROGRAMMING 719 How do Prolog rules work? To understand how the betterdeal rule works, IInor need to perform bit of magic to determine the price per square inch of each pizza In the completed pizza program, the computer can calculate the square-inch price using rule the programmer provides. Because you don't yet have such rule, temporarily assume that the square-inch price of the first pizza is .0694 (6 .94 cents and the square-inch price of the second pizza is .0779 (7.79 cents) These facts be stated as: square nchpri .ce (pizzal 0694 and square inchpr ice (pizza2 0779 Now, suppose you enter the query ?- betterdeal (pi izzal pizza2) FIGURE 12.49 which translates to Is pizza1 better deal than pizza2?* Figure 12-49 illus Prolog executes the betterdeal trates how Prolog uses the bet ...